package com.cn.serverline.lineicp.productionLine.controller;

import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import javax.annotation.Resource;

import com.cn.serverline.lineicp.productionLine.param.ProcessMaterialsAddParam;
import com.cn.serverline.lineicp.productionLine.param.ProcessMaterialsEditParam;
import com.cn.serverline.lineicp.productionLine.param.ProcessMaterialsIdParam;
import com.cn.serverline.lineicp.productionLine.param.ProcessMaterialsPageParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import com.cn.serverline.lineicp.productionLine.entity.ProcessMaterials;
import com.cn.serverline.lineicp.productionLine.service.IProcessMaterialsService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * 工序物料 接口
 *
 * @author Gmr
 * @since 2024-07-31
 */
@RestController
@ApiResource(name = "工序物料的接口")
@Api(tags = "工序物料")
public class ProcessMaterialsController {

    @Resource(name = "ProcessMaterialsServiceImpl")
    private IProcessMaterialsService iProcessMaterialsService;

    /**
     * 添加工序物料
     */
    @ApiOperation("添加工序物料")
    @PostResource(name = "添加工序物料", path = "/productionLine/processMaterials/add")
    public ResponseData<?> add(@RequestBody @Validated ProcessMaterialsAddParam processMaterials){
        iProcessMaterialsService.add(processMaterials);
        return new SuccessResponseData<>();
    }

    /**
     * 删除工序物料
     */
    @ApiOperation("删除工序物料")
    @PostResource(name = "删除工序物料", path = "/productionLine/processMaterials/delete")
    public ResponseData<?> delete(@RequestBody @Validated ProcessMaterialsIdParam idParam){
        iProcessMaterialsService.del(idParam);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑工序物料
     */
    @ApiOperation("编辑工序物料")
    @PostResource(name = "编辑工序物料", path = "/productionLine/processMaterials/edit")
    public ResponseData<?> edit(@RequestBody @Validated ProcessMaterialsEditParam editParam) {
        iProcessMaterialsService.edit(editParam);
        return new SuccessResponseData<>();
    }

    /**
     * 分页查询-工序物料列表
     */
    @ApiOperation("分页查询-工序物料列表")
    @GetResource(name = "分页查询-工序物料列表", path = "/productionLine/processMaterials/page")
    public ResponseData<PageResult<ProcessMaterials>> page(@Validated ProcessMaterialsPageParam pageParam) {
        return new SuccessResponseData<>(iProcessMaterialsService.findPage(pageParam));
    }

}
